home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14197 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: babel.ho.att.com!joe
  2. From: joe@sanskrit.ho.att.com (Joe Orost)
  3. Newsgroups: comp.programming,comp.lang.c
  4. Subject: Bug in SkipList code [Feb'91 C User's Journal]
  5. Date: 12 Apr 96 13:37:12 GMT
  6. Organization: AT&T Bell Laboratories, Columbus, Ohio
  7. Message-ID: <joe.829316232@babel.ho.att.com>
  8. NNTP-Posting-Host: sanskrit.ho.att.com
  9.  
  10. I found a bug in the SkipList code [Feb'91 C User's Journal].
  11.  
  12. In "delete", the following lines are wrong:
  13.  
  14.         while((i = lnode->korl.level) > 1
  15.             && lnode->pointers[i] == NIL)
  16.         {
  17.             lnode->korl.level = --i;
  18.         }
  19.  
  20. Bug is because lnode->pointers[level] does not exist!  The last valid
  21. entry is lnode->pointers[level-1].
  22.  
  23. Here is the correct code:
  24.  
  25.         while((i = lnode->korl.level - 1) > 0
  26.             && lnode->pointers[i] == NIL)
  27.         {
  28.             --i;
  29.         }
  30.         lnode->korl.level = i + 1;
  31.  
  32.                                 regards,
  33.                                 joe
  34.  
  35. --
  36. Full Name:    Joseph M. Orost
  37. EMail:        Joseph.Orost@att.com, attmail!orost
  38. Organization: AT&T Labs: Technology Realization
  39. SurfaceMail:  943 Holmdel Rd.; Cruz Plaza; Holmdel, NJ 07733
  40. Phone:        +1 (908) 946-1115
  41. Fax:          +1 (908) 946-9146
  42.